package com.beiding.my.mql;

import com.beiding.my.mql.utils.KeywordBlock;
import com.beiding.my.mql.utils.MqlUtils;

import java.util.List;
import java.util.Map;

public abstract class MQLCompiler {

    //group by和order by属于组合关键字
    private static final String[] keywords = new String[]{"select", "insert into", "delete from", "update", "from", "where", "group by", "having", "order by", "limit", "union", "on", "left join", "right join", "drop", "alter", "add"};

    public abstract CompilerDetails compile(List<String> mqls);

    public abstract String getCommand();

    public abstract String[] segmentKeywords();

    protected Map<String, KeywordBlock> getSegmentMap(String mql) {

        //从一个mql中找到声明的关键词对应的内容
        return MqlUtils.makeSegmentMap(mql, keywords, segmentKeywords());
    }

}
